package main
 
import (
    "encoding/json"
    "fmt"
    "time"
)
 
type Server struct {
    ServerName string `json:"serverName"`
    ServerIP   string `json:"serverIP"`
    CreatedAt time.Time`json:"CreatedAt"`
}
 
type Serverslice struct {
    Servers []Server `json:"servers"`
}
 
func main() {
 
    var s Serverslice
    s.Servers = append(s.Servers, Server{CreatedAt:time.Now(),ServerName: "Shanghai_VPN", ServerIP: "127.0.0.1"})
    s.Servers = append(s.Servers, Server{CreatedAt:time.Now(),ServerName: "Beijing_VPN", ServerIP: "127.0.0.2"})
 
    b, err := json.Marshal(s)
    if err != nil {
        fmt.Println("json err: ", err)
    }
 
    fmt.Println(string(b))
 
    var f interface{}
    err2 := json.Unmarshal(b, &f)
    if err2 != nil {
        fmt.Println(err2)
    }
    m := f.(map[string]interface{})
    for k, v := range m {
        switch vv := v.(type) {
        case string:
            fmt.Println(k, "is string", vv)
        case int:
            fmt.Println(k, "is int", vv)
        case []interface{}:
            fmt.Println(k, "is an array:")
            for i, u := range vv {
                fmt.Println(i, u)
            }
        default:
            fmt.Println(k, "is of a type I don't know how to handle")
        }
    }
}